package ooday04;

public class Test {
    public static void main(String[] args) {
        /*
        Master master=new Master();
        Dog dog=new Dog("小花",2,"黄色");
        Fish fish=new Fish("布丁", 2, "白色");
        Chick chick=new Chick("果冻", 2, "白色");
        master.feed(dog);
        master.feed(fish);
        master.feed(chick);
         */


        Animal[] animals = new Animal[5];
        animals[0] = new Dog("小花", 2, "黄色");
        animals[1] = new Dog("小黑", 1, "黑色");
        animals[2] = new Fish("布丁", 2, "白色");
        animals[3] = new Fish("汤圆", 2, "灰色");
        animals[4] = new Chick("果冻", 2, "白色");
        for (int i = 0; i < animals.length; i++) {
            System.out.println(animals[i].name);
            animals[i].druik();
            animals[i].eat();
            if (animals[i] instanceof Dog) {
                Dog dog = (Dog) animals[i];
                dog.housekeeping();
                dog.swim();
            }
            if (animals[i] instanceof Chick) {
                Chick chick = (Chick) animals[i];
                chick.layegg();
            }
            if (animals[i] instanceof Fish) {
                Fish fish = (Fish) animals[i];
                fish.swim();
            }
        }


    }
}
